package com.xinqing.bigdata.rdd

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
  * @Author:CHQ
  * @Date:2020 /6/19 15:27
  * @Description
  */
object CheckPoint {
  def main(args: Array[String]): Unit = {
    val sparkConf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("word count")
    val sparkContext: SparkContext = new SparkContext(sparkConf)
    sparkContext.setCheckpointDir("cp")
    val inputRDD: RDD[Int] = sparkContext.makeRDD(List(1, 2, 3, 4))
    val mapRDD: RDD[(Int, Int)] = inputRDD.map((_, 1))
    val reduceRDD: RDD[(Int, Int)] = mapRDD.reduceByKey(_ + _)
    reduceRDD.checkpoint()
    reduceRDD.foreach(println)
  }
}

